package com.siruier.boss.ui.widget;

import android.text.TextPaint;
import android.view.View;

import androidx.annotation.NonNull;

/**
 * Created by zhoucl on 2019/4/5.
 */
public class BpClickableSpan extends android.text.style.ClickableSpan {
    private com.siruier.boss.ui.widget.UnSpanText unSpanText;
    private View.OnClickListener mOnClickListener;

    public BpClickableSpan(UnSpanText unSpanText, View.OnClickListener onClickListener) {
        this.unSpanText = unSpanText;
        this.mOnClickListener = onClickListener;
    }

    @Override
    public void onClick(View widget) {
        if (mOnClickListener != null)
            mOnClickListener.onClick(widget);
    }

    @Override
    public void updateDrawState(@NonNull TextPaint ds) {
        super.updateDrawState(ds);
//        ds.setFakeBoldText(true);
//        if (unSpanText != null)
//            ds.setColor(unSpanText.getColorId() == 0 ? ContextCompat.getColor(AppUtils.app, R.color.main_color) : unSpanText.getColorId());
//        else ds.setColor(ContextCompat.getColor(AppUtils.app, R.color.main_color));
        ds.setUnderlineText(false);
    }
}
